Twitter – matoken's blog https://matoken.org/blog Is there no plan B? Tue, 31 Dec 2024 21:06:28 +0000 ja hourly 1 https://wordpress.org/?v=6.8.1 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg Twitter – matoken's blog https://matoken.org/blog 32 32 Bufferを経由してold TwitterへWordPress投稿を通知 https://matoken.org/blog/2024/12/31/wp-to-buffer/ https://matoken.org/blog/2024/12/31/wp-to-buffer/#respond Tue, 31 Dec 2024 09:18:53 +0000 https://matoken.org/blog/?p=4315

このweblogをold Twitterへの投稿をTwitter API利用がBANされてIFTTTに切り替え,Twitterの規約変更からIFTTT有料化でseleniumを使って投稿するように.しかし回線のせいか失敗することのほうがが多いです.ということで最近はBufferを利用しています.

Bufferのwebインターフェイスを起動して投稿をするのに回線が細いと数分かかり面倒.拡張機能を使うと2回目以降キャッシュが利いていると結構さくっと投稿できていい感じです.

更に楽にするようAPIを叩いてBufferに渡すコマンドを書こうかと思いましたがどうも2019年にBuffer APIの受付は終わってしまったようです.
そこで「WP to Buffer」というWordPress pluginを試してみました.

WordPress pluginページからWP to Bufferを導入,有効化,自動更新も有効化しました.
WP to Bufferの「Settings」の「Authentication」でBufferと連携します.
「投稿」→「Defaults」の「Publish」の右上の「Enabled」にチェックが付いている状態で投稿内容を設定します.とりあえず規定値のままで.
「Publish」の右隣の「Update」の「Enabled」はチェックを外してblog更新時には投稿しないようにしました.

投稿タブ左側にBuffer連携済のSNSが表示されるので,連携したいSNSを押して「Account Enabled」にチェックを付けます.

WP to Buffer

これで恐らく投稿時にチェックを付けたSNSにBuffer経由で投稿されるようになったと思います.
このエントリがテストです,

WP to Bufferに課金してProにUpgradeすると便利な機能が色々と使えるようになるようです.

しかしここ1月のt.coからのアクセスを確認してみると2件なのでそもそもTwitter連携をする意味はあまりない気がしてきました…….

追記)

こんな感じでBufferのQueueに登録され,順次投稿されるようです.WP to BufferをProにするとこの辺りの投稿タイミングも指定できそうです.(未確認)

Buffer Queue
Buffer to Twitter

]]>
https://matoken.org/blog/2024/12/31/wp-to-buffer/feed/ 0
TwitterクライアントのFritterの復活とFeedの削除と,Feedの使えるforkのQuacker https://matoken.org/blog/2023/05/24/twitter-client-friter-and_quacker/ https://matoken.org/blog/2023/05/24/twitter-client-friter-and_quacker/#respond Tue, 23 May 2023 20:45:00 +0000 https://matoken.org/blog/?p=3901

Fritterというログイン不要でTwitterの購読ができるAndroid用のTwitter clientがあります.

既存Twitterアカウントからフォローをインポートしたり,購読グループを複数作成したりと便利なのですが,安定版は近ごろのTwitterの仕様変更などにより利用できなくなっていました.
Nitterは対応していたのでそのうち対応されるかもと思っていたら以下のような通知が.

An update for Fritter is available!🚀

An update for Fritter is available!🚀
Update to v3.0.0-beta9 through your FDroid client

アップデートが出たようです.早速F-Droidを起動して更新します…….リポジトリを更新しても更新に出てきません.
F-DroidのFritterのページの下のバージョンをタップして,v3.0.0-beta9を選んで導入しました.

f droid

導入後起動すると,各ユーザのタイムラインが閲覧できるようになりました :)

しかし,以前あったfeedタブが見当たりません.設定にも特に無さそう.
issueを確認したところ以下のようなものが.feed機能は削除されたようです.

TLDR; I’m not going to be reinstating the feed, as it’s too hard to maintain and bad for people’s mental health.

まあわかるけど一人ひとり確認するのは不便です.

Fritterをforkしてfeed機能を復活させた方がいました.Quackerというようです.🦆

Quacker

アヒルのアイコンが可愛いですね.

QuackerはF-Droid規定値のリポジトリの中にはないようです.以下から手動でダウンロードするか,

F-Droidにリポジトリを追加( https://apt.izzysoft.de/fdroid/repo )して,リポジトリを更新してQuackerを検索して導入します.

F Droid Quacker repo
F Droid Quacker install

あとはFritterから設定をエクスポートして,Quackerで設定をインポートすることで以前のFritterのように使えるようになりました.

まあ,Twitterによりまたすぐに動かなくなるかもしれませんが…….

]]>
https://matoken.org/blog/2023/05/24/twitter-client-friter-and_quacker/feed/ 0
TwidereをTwidere XのAPI Keyに変更して投稿できるようにする 2023-01-16 https://matoken.org/blog/2023/01/16/change-twidere-to-twidere-x-api-key/ https://matoken.org/blog/2023/01/16/change-twidere-to-twidere-x-api-key/#respond Mon, 16 Jan 2023 14:49:27 +0000 https://matoken.org/blog/?p=3812

最近のTwitterの使い方はこんな感じ

このTwidereでのTwitter投稿が失敗するようになりました.
Twitterは最近色々と変わったりしているしそのうち治るかなと思ったけど治りません.

他のクライアントはどうだろうとoysttyerを試すとpost出来ました.

認証し直したら行けるのかな?とTwidereでログインし直そうとすると認証できません.
クライアントの認証方式の違いのせいなのかな?とTwidereのissueを見るとTwidere XのTwitter API keyに変更すると動くようになるというものが有りました.

What worked for me is:

Go to Settings > Network > Avanced > Default API Settings
Replace the consumer key and consumer secret with those above and save
Go to Accounts and click the + in the top right
Choose Twitter > User Settings
Click Register, then the Sign In button, this should take you to an authorization page
Go through the authorization steps
Refresh your timelines

これを試すと投稿できるようになりました.ということはTwitterは特定のクライアントを拒否するようにしているみたいですね…….
まあ明日には変わっているかもしれませんが.

以下日本語環境でのメモ.

twidere api01
twidere api02
twidere api03
twidere api04
twidere api05
twidere api06
twidere api07
twidere api08
twidere api09
twidere api10
twidere api11

]]>
https://matoken.org/blog/2023/01/16/change-twidere-to-twidere-x-api-key/feed/ 0
Twitter Spacesをダウンロードして無音部分をカットして聞く https://matoken.org/blog/2022/03/17/download-twitter-spaces-and-cut-the-silence-to-listen/ https://matoken.org/blog/2022/03/17/download-twitter-spaces-and-cut-the-silence-to-listen/#respond Wed, 16 Mar 2022 21:09:36 +0000 http://matoken.org/blog/?p=3544

Twitter Scapesという音声配信サービスがありますが,基本的にライブ.聴きたいものがあったのですが,体調不良で寝ていて聞けませんでした.
でも30日アーカイブが残るとのことなのでダウンロードしてスマホで聞いてみました.

まずはダウンロード,Youtube-dl, yt-dlpを試しましたがまだ未対応のよう.

今回Twspace-dlというものを試しました.

$ virtualenv .
$ source bin/activate
$ pip install twspace-dl
$ twspace_dl
usage: twspace_dl [-h] [-v] [-s] [-k] [-l] [--input-cookie-file COOKIE_FILE] [--username USERNAME]
                  [--password PASSWORD] [--output-cookie-file OUTPUT_COOKIE_FILE] [-i SPACE_URL | -U USER_URL]
                  [-d DYN_URL] [-f URL] [-M PATH] [-o FORMAT_STR] [-m] [-p] [-u] [--write-url URL_OUTPUT]

Script designed to help download twitter spaces

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose
  -s, --skip-download
  -k, --keep-files
  -l, --log             create logfile
  --input-cookie-file COOKIE_FILE

input:
  -i SPACE_URL, --input-url SPACE_URL
  -U USER_URL, --user-url USER_URL
  -d DYN_URL, --from-dynamic-url DYN_URL
                        use the dynamic url for the processes(useful for ended spaces) example: https://prod-
                        fastly-ap-
                        northeast-1.video.pscp.tv/Transcoding/v1/hls/zUUpEgiM0M18jCGxo2eSZs99p49hfyFQr1l4cdze-
                        Sp4T-DQOMMoZpkbdyetgfwscfvvUkAdeF-I5hPI4bGoYg/non_transcode/ap-northeast-1/periscope-
                        replay-direct-prod-ap-northeast-1-public/audio-space/dynamic_playlist.m3u8?type=live
  -f URL, --from-master-url URL
                        use the master url for the processes(useful for ended spaces) example: https://prod-
                        fastly-ap-northeast-1.video.pscp.tv/Transcoding/v1/hls/YRSsw6_P5xUZHMualK5-ihvePR6o4Qmo
                        ZVOBGicKvmkL_KB9IQYtxVqm3P_vpZ2HnFkoRfar4_uJOjqC8OCo5A/non_transcode/ap-
                        northeast-1/periscope-replay-direct-prod-ap-northeast-1-public/audio-
                        space/master_playlist.m3u8
  -M PATH, --input-metadata PATH
                        use a metadata json file instead of input url (useful for very old ended spaces)

output:
  -o FORMAT_STR, --output FORMAT_STR
  -m, --write-metadata  write the full metadata json to a file
  -p, --write-playlist  write the m3u8 used to download the stream(e.g. if you want to use another downloader)
  -u, --url             display the master url
  --write-url URL_OUTPUT
                        write master url to file

login:
  --username USERNAME
  --password PASSWORD
  --output-cookie-file OUTPUT_COOKIE_FILE

早速ダウンロード

$ twspace_dl -i https://twitter.com/i/spaces/1ypKdEXLdLqGW

2022-03-16 15:42:16,496 [INFO] ./tmp6swcs0w5/(辻 伸弘 (nobuhiro tsuji))ゆくアレ、くるアレ #セキュリティのアレ-1ypKdEXLdLqGW.m3u8 written to disk
[hls @ 0x55f2ea4a9800] Changing ID3 metadata in HLS audio elementary stream is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
size=   51141kB time=01:13:21.68 bitrate=  95.2kbits/s speed=10.6x
2022-03-16 15:49:14,334 [INFO] Finished downloading
$ ffprobe -i ./\(辻\ 伸弘\ \(nobuhiro\ tsuji\)\)ゆくアレ、くるアレ\ #セキュリティのアレ-1ypKdEXLdLqGW.m4a
ffprobe version 4.4.1-3+b2 Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 11 (Debian 11.2.0-18)
  configuration: --prefix=/usr --extra-version=3+b2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './(辻 伸弘 (nobuhiro tsuji))ゆくアレ、くるアレ #セキュリティのアレ-1ypKdEXLdLqGW.m4a':
  Metadata:
    major_brand     : M4A
    minor_version   : 512
    compatible_brands: M4A isomiso2
    title           : ゆくアレ、くるアレ #セキュリティのアレ
    artist          : 辻 伸弘 (nobuhiro tsuji)
    encoder         : Lavf58.76.100
    episode_id      : 1ypKdEXLdLqGW
  Duration: 01:13:21.71, start: 0.000000, bitrate: 95 kb/s
  Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 93 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]

ダウンロードできました.再生してみると音が出ない??先頭に無音が入ってるせいで少し進めると音が出ました.

てことで先日も使った ffmppegsilenceremove フィルタで無音部分をカットします.

しきい値は前回と同じ -90dB だとほとんどカットできまぜんでした. -50dB でいい感じになったようです.

$ ffmpeg -i ./\(辻\ 伸弘\ \(nobuhiro\ tsuji\)\)ゆくアレ、くるアレ\ #セキュリティのアレ-1ypKdEXLdLqGW.m4a -af silenceremove=stop_periods=-1:stop_duration=1:stop_threshold=-50dB -acodec libopus ./\(辻\ 伸弘\ \(nobuhiro\ tsuji\)\)ゆくアレ、くるアレ\ #セキュリティのアレ-1ypKdEXLdLqGW.opus

01:13:21.71 → 01:09:51.71 になりました.てことでこれでスマホに転送して聞くことが出来ました.

Twitter Space podcast 50

ちなみに今回試した配信はPodcastの「セキュリティのアレ」の「サイバーセキュリティに関する総務大臣奨励賞」の受賞記念配信的なものでした.いつもは週一くらいでPodcastを配信されています.

#最近はPodcastの露出が増えている感じ.過去に配信して止まっている番組も復活しないかな電カーとかちんさんとか…….

環境
$ dpkg-query -W python3 ffmpeg
ffmpeg  7:4.4.1-3+b2
python3 3.9.8-1
$ lsb_release -dr
aDescription:   Debian GNU/Linux bookworm/sid
Release:        unstable
$ arch
x86_64
]]>
https://matoken.org/blog/2022/03/17/download-twitter-spaces-and-cut-the-silence-to-listen/feed/ 0
Twitterクライアントsayakaちゃんの最新版(3.5.0)をLinuxでビルドする https://matoken.org/blog/2021/03/06/build-the-latest-version-3-5-0-of-twitter-client-sayaka-on-linux/ https://matoken.org/blog/2021/03/06/build-the-latest-version-3-5-0-of-twitter-client-sayaka-on-linux/#respond Sat, 06 Mar 2021 13:32:34 +0000 http://matoken.org/blog/?p=3052

追記2021-03-09)
Raspberry Pi OS buster armhf 及び Ubuntu 21.04 (development branch) amd64でも同様にビルドできました :)

ターミナルで動作するTwitterクライアントとしてsayakaちゃんというものがあります.NetBSDの入ったSHARP X68030でも動作するという軽量なクライアントで,SIXELで画像が表示できたりストリームモードがあってハッシュタグなどを垂れ流すのに便利に使っています.

今日オープンソースカンファレンス2021 Online/Spring 2日目があって @ebijunさんの「NetBSDのご紹介」 を視聴していたのですが,新しいバージョンの 3.5.0 がリリースされたとのことで試してみました.

twitter クライアント sayaka ちゃん version 3.5.0 (2021/03/03)
ターミナルに特化した twitter クライアントです。

フィルタストリームの垂れ流しが出来ます。
フィルタストリームによる疑似ホームタイムラインが表示できます。
mlterm などの SIXEL 対応ターミナル用です。
X68030/25MHz、メモリ12MB でも快適(?)動作。
更新履歴
3.5.0 (2021/03/03) … C++ に移行し vala 版廃止。 画像は現在のところ JPEG, PNG のみ対応。 ターミナル背景色の自動取得を実装。 --protect、--support-evs オプション廃止。 --noimg オプションを廃止 (--no-image に変更)。 userstream 時代の録画データの再生機能廃止。

watchしてたけどメール届いていないようです?

sayaka watch

現在のバーションを確認してみます.1つ前のバージョンぽいですね.

$ sayaka --version
sayaka.vala 3.4.6 (2020/11/10)

ビルドを試みます.

$ git clone https://github.com/isaki68k/sayaka/ (1)
$ cd sayaka
$ git checkout 3.5.0
HEAD is now at 958f630 ver 3.5.0 (2021/03/03)
$ ./configure (2)
  1. sayakaのsourceをclone
  2. configure

足りないものがパッケージ名で表示されて助かります :)

configure: error: *** mbedtls not found.
        On Ubuntu, sudo apt install libmbedtls-dev
configure: error: *** mbedtls not found.
        On Ubuntu, sudo apt install libmbedtls-dev

./configure が通ったらmake……失敗です.

$ make
(cd src; make all)
make[1]: Entering directory '/home/matoken/src/sayaka/src'
Makefile:3: *** missing separator.  Stop.
make[1]: Leaving directory '/home/matoken/src/sayaka/src'
make: *** [Makefile:2: all] Error 2

必要なものをよく見ると,GNU makeではなく BSD make が必要となっていました.(3.4.6を確認するとこのときはGNU makeなので今回変わったようです)

必要なもの
C++17 compiler
jpeg (libjpeg)
libpng
mbedtls (2.9.0 or later?)
BSD make (not GNU make)

BSD makeを導入してGNU makeではなくBSD makeを使います.

$ sudo apt install bmake (1)
$ bmake sayaka (2)
$ src/sayaka --version (3)
sayaka version 3.5.0 (2021/03/03)
$ install src/sayaka ~/bin/ (4)
  1. BSD makeを導入
  2. BSD makeでsayakaをmake
  3. 出来上がったsayakaを叩いてみる
  4. sayakaを適当な場所( ~/bin )にコピーにinstall

ということでsayaka 3.5.0 にできました :)

私はmlterm等のSIXEL対応端末で検索したいキーワードを繋げていってデスクトップの横においておくといった感じで使っています.

環境
$ sayaka --version
sayaka version 3.5.0 (2021/03/03)
$ ldd src/sayaka | cut -f1 -d"(" | cut -f3 -d" " | xargs -n1 apt-file search | cut -f1 -d: | uniq | xargs dpkg-query -W | grep amd64
libbsd0:amd64   0.11.3-1
libc6:amd64     2.31-9
libgcc-s1:amd64 10.2.1-6
libjpeg62-turbo:amd64   1:2.0.6-2
libmbedcrypto3:amd64    2.16.9-0.1
libmbedtls12:amd64      2.16.9-0.1
libmbedx509-0:amd64     2.16.9-0.1
libmd0:amd64    1.0.3-3
libpng16-16:amd64       1.6.37-3
libstdc++6:amd64        10.2.1-6
zlib1g:amd64    1:1.2.11.dfsg-2
$ dpkg-query -W bmake build-essential
bmake   20200710-7
build-essential 12.9
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64
]]>
https://matoken.org/blog/2021/03/06/build-the-latest-version-3-5-0-of-twitter-client-sayaka-on-linux/feed/ 0
TTY TwitterクライアントのTTYtterからOysttyerに乗り換え https://matoken.org/blog/2021/02/19/switch-from-ttytter-a-tty-twitter-client-to-oysttyer/ https://matoken.org/blog/2021/02/19/switch-from-ttytter-a-tty-twitter-client-to-oysttyer/#respond Fri, 19 Feb 2021 13:05:37 +0000 http://matoken.org/blog/?p=3012

TTYtterというPerl製でcliで動作するTwitter clientがあります.自作Twitter投稿scriptがアカウントをBANされてAPI keyが使えなくなった後これを使って自動投稿などをしていたのですが,Debian busterから無くなっています.
開発元を見るとOysttyerというものが変わりに存在するようなのでそちらに乗り換えました.

TTYtterからOysttyerに乗り換えるには認証鍵などを作り直す必要があるようです.
-oauthwizard オプションで認証ができるようです.
既定値では認証情報は ~/.oysttyerkey に保存されますが,複数のTwitterアカウントで利用したいので -key=認証情報格納ファイル オプションを付けて区別します.

Note
-keyf のパスに ~ を使うとエラーになるようです.今回は代わりに $HOME を使いました.
$ oysttyer -keyf=$HOME/.oysttyerkey_kagolug_ml -oauthwizard (1)
-- using SSL for default URLs.
trying to find cURL ... /usr/bin/curl
-- Streaming API disabled (no -dostream) (oysttyer will use REST API only)
-- no version check performed (use /vcheck, or -vcheck to check on startup)

+------------------------------------------------------------------------------+
|| WELCOME TO oysttyer: Authorize oysttyer by signing into Twitter with OAuth ||
+------------------------------------------------------------------------------+
Looks like you're starting oysttyer for the first time, and/or creating a
keyfile. Welcome to the most user-hostile, highly obfuscated, spaghetti code
infested and obscenely obscure Twitter client that's out there. You'll love it.

oysttyer generates a keyfile that contains credentials for you, including your
access tokens. This needs to be done JUST ONCE. You can take this keyfile with
you to other systems. If you revoke oysttyer's access, you must remove the
keyfile and start again with a new token. You need to do this once per account
you use with oysttyer; only one account token can be stored per keyfile. If you
have multiple accounts, use -keyf=... to specify different keyfiles. KEEP THESE
FILES SECRET.

** This wizard will overwrite ~/.oysttyerkey_kagolug_ml
Press RETURN/ENTER to continue or CTRL-C NOW! to abort.
(2)
Request from https://api.twitter.com/oauth/request_token ... SUCCEEDED!

1. Visit, in your browser, ALL ON ONE LINE,

https://api.twitter.com/oauth/authorize?oauth_token=lfqqTgAAAAAAixnPABABd7YG56I (3)

2. If you are not already signed in, fill in your username and password.

3. Verify that oysttyer is the requesting application, and that its permissions
are as you expect (read your timeline, see who you follow and follow new
people, update your profile, post tweets on your behalf and access your
direct messages). IF THIS IS NOT CORRECT, PRESS CTRL-C NOW!

4. Click Authorize app.

5. A PIN will appear. Enter it below.

Enter PIN> 0901765 (4)

Request from https://api.twitter.com/oauth/access_token ... SUCCEEDED!
Written keyfile /home/mk/.oysttyerkey_kagolug_ml

Now, restart oysttyer to use this keyfile.
(To choose between multiple keyfiles other than the default .oysttyerkey,
tell oysttyer where the key is using -keyf=... .)
  1. 認証ファイルを指定して認証処理実行
  2. Enterで続行
  3. URLをコピーしてウェブブラウザにて認証したいTwitterアカウントで許可する
  4. ウェブブラウザに表示されるPINを入力してEnter

これで認証情報が指定ファイルに格納されます.

TTYtterではScript中から以下のようにして投稿を行っていました.

ttytter -keyf=/home/mk/.ttytterkey-kagolug_ml -location -lat=31.5775639 -long=130.6667937 -status="$MESSAGE"

Oysttyerのユーザガイドのコマンドラインオプションを確認するとそのまま使えそうです.

コマンドと認証鍵ファイルを変更するだけで動作しました.

$ oysttyer -keyf=/home/mk/.oysttyerkey_kagolug_ml -location -lat=31.5775639 -long=130.6667937 -status="投稿テスト📮"
-- using SSL for default URLs.
trying to find cURL ... /usr/bin/curl
test-login SUCCEEDED!
post attempt -- using lat/long: (31.5775639, 130.6667937)
SUCCEEDED!

Scriptも同様にコマンドと鍵ファイルを書き換えました.これでbuster以降でも大丈夫なはずです :)

環境
$ dpkg-query -W oysttyer chromium
chromium        88.0.4324.146-1~deb10u1
oysttyer        2.10.0-1
$ lsb_release -dr
Description:    Debian GNU/Linux 10 (buster)
Release:        10
$ uname -m
x86_64
]]>
https://matoken.org/blog/2021/02/19/switch-from-ttytter-a-tty-twitter-client-to-oysttyer/feed/ 0
軽量TwitterフロントエンドのNitterをセルフホスト https://matoken.org/blog/2021/02/17/self-hosting-the-lightweight-twitter-front-end-nitter/ https://matoken.org/blog/2021/02/17/self-hosting-the-lightweight-twitter-front-end-nitter/#comments Wed, 17 Feb 2021 13:34:23 +0000 http://matoken.org/blog/?p=3007

NitterというTwitterのフロントエンドがあります.最近はTwitterが重くてなにか検索しようと思っても待ち長かったり画像読み込み失敗したりといったこともよくあります(PCのスペックと回線が細いせいも大きいですが).軽量ブラウザを使ったりもしてみましたがそうすると見た目や使い勝手がいまいち.

そして現在そういった軽量ブラウザは利用もできなくなりました.

This browser is no longer supported.
Please switch to a supported browser to continue using twitter.com. You can see a list of supported browsers in our Help Center.

そこで Nitter を試してみたところ軽くていい感じです.

現在ログイン機能はないので,投稿や非公開Tweetや非公開リストなどは使えませんが,イベントのハッシュタグを追ったり,過去のtweetを検索といったことをするのに便利です.

RSS形式での出力にも対応しています.

軽量で便利なのでロカールマシンでNitterを動かして外にURLを共有するときは https://nitter.net/ を利用していました.

という話を以前オープンソースカンファレンス2020福岡内の鹿児島らぐのコマで発表しました.

しかし,最近は https://nitter.net/ がTwitterの制限に掛かって利用できないことが多くなってきました.なので自分のVPS上にホストしてみました.

Note
同じ手順で Raspberry Pi OS buster armhf や Debian sid(nimはDebinaパッケージのもの利用)でも動作しました.

Nitterのインストール環境の用意

Nitterが依存している Redislibsass を導入しておきます.

$ sudo apt install redis-server libsass-dev

Nitterを専用アカウントで動かしたいので nitter ユーザ,グループを作ってそのユーザで操作します.

$ sudo groupadd nitter (1)
$ sudo useradd -m -g nitter nitter (2)
$ sudo -iu nitter (3)
  1. nitter グループを作成
  2. nitter ユーザを作成
  3. nitter ユーザのシェルを開く

nimの用意

Nitterはnim-langで出来ています.Nitterのコンパイルにはnim 1.2.0以上が必要ですが,Debian busterのパッケージ版のnimは 0.19.4 でコンパイル出来ません.buster-backports も 1.0.4-1~bpo10+1 と対応していません.(bullseyeは1.4.2)

$ nimble build -d:release
  Verifying dependencies for nitter@0.1.0
       Tip: 2 messages have been suppressed, use --verbose to show them.
     Error: Unsatisfied dependency: nim (>= 1.2.0)
$ dpkg-query -W nim
nim     0.19.4-1

とりあえずnimの公式サイトのバイナリを利用してコンパイルすることにします.

$ wget https://nim-lang.org/download/nim-1.4.2-linux_x64.tar.xz \
https://nim-lang.org/download/nim-1.4.2-linux_x64.tar.xz.sha256 (1)
$ sha256sum -c ./nim-1.4.2-linux_x64.tar.xz.sha256 (2)
nim-1.4.2-linux_x64.tar.xz: OK
$ tar tvf nim-1.4.2-linux_x64.tar.xz | lv (3)
$ tar xvf nim-1.4.2-linux_x64.tar.xz (4)
  1. nimのバイナリをダウンロード
  2. hash確認
  3. アーカイブ確認
  4. アーカイブ展開

Nitterのコンパイル

Nitterのsourceをcloneしてさっきダウンロードして展開したnimでコンパイルします.

$ git clone https://github.com/zedeus/nitter
$ cd nitter
$ PATH=~/nim-1.4.2/bin:$PATH nimble build -d:release
$ PATH=~/nim-1.4.2/bin:$PATH nimble scss
$ mkdir ./tmp

Redis が起動しているのを確認して nitter を起動してみます.この状態で 8080 ポートにアクセスして Nitter が利用できるのを確認します.ポート番号などは nitter.conf で変更できます.

$ ps -ef|grep -i redis (1)
redis    11786     1  0 Feb11 ?        00:15:28 /usr/bin/redis-server 127.0.0.1:6379
$ ./nitter & (2)
$ w3m http://localhost:8080/ (3)
$ kill %1 (4)
$ exit (5)
  1. Redisが動いているのを確認
  2. Nitterを起動
  3. Nitterの動作を確認
  4. Nitterを終了
  5. nitter アカウントから抜ける

Nitterの起動設定

次にNitterに起動設定を行います.Systemd環境なので以下のようなサービスファイルを用意しました.

/etc/systemd/system/nitter.service
[Unit]
Description=Nitter (An alternative Twitter front-end)
After=syslog.target
After=network.target

[Service]
Type=simple

# set user and group
User=nitter
Group=nitter

# configure location
WorkingDirectory=/home/nitter/nitter
ExecStart=/home/nitter/nitter/nitter

Restart=always
RestartSec=15

[Install]
WantedBy=multi-user.target

サービスを有効にしてNitterを起動します.

$ sudo systemctl enable --now nitter.service
$ systemctl status nitter
● nitter.service - Nitter (An alternative Twitter front-end)
   Loaded: loaded (/etc/systemd/system/nitter.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2021-02-17 01:13:07 JST; 34s ago
 Main PID: 19702 (nitter)
    Tasks: 1 (limit: 4696)
   Memory: 3.6M
   CGroup: /system.slice/nitter.service
           └─19702 /home/nitter/nitter/nitter
$ w3m http://localhost:8080/

外に公開せず,ローカルで動作させる場合はここまでの手順でOKです.

ドメインとSSL証明書の用意

※この手順はローカルで動かす場合は必要ありません.

今回はサブドメインを用意しました.DNSを設定して nitter.matoken.org を用意しました.設定ミスしたときにリカバリしやすいようにTTlを短く設定してうまく行ったらいつもの長さにします.

証明書はcertbotを使いLet’s encryptで作成しました.

$ sudo certbot certonly -d nitter.matoken.org

apache httpdの用意

※この手順はローカルで動かす場合は必要ありません.

Nitterをそのまま外に公開するのはセキュリティ的に良くないということで,apache httpdでhttpdの処理をしてNitterの8080に転送するようにしました.

Nitter用のapache httpd設定ファイルを用意します.

/etc/apache2/sites-available/nitter.matoken.org.conf
<VirtualHost *:80>
        ServerName nitter.matoken.org
        Redirect permanent / https://nitter.matoken.org/
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName nitter.matoken.org
        ServerAdmin webmaster@matoken.org

        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>

        ProxyPreserveHost On
        ProxyPass / http://127.0.0.1:8080/ nocanon
        ProxyPassReverse / http://127.0.0.1:8080/
        AllowEncodedSlashes On

        ErrorLog ${APACHE_LOG_DIR}/error.nitter.matoken.org.log
        CustomLog ${APACHE_LOG_DIR}/access.nitter.matoken.org.log combined

        SSLCertificateFile /etc/letsencrypt/live/nitter.matoken.org/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/nitter.matoken.org/privkey.pem

</VirtualHost>
</IfModule>

設定を有効にしてテスト後反映します.

$ sudo a2ensite nitter.matoken.org.conf (1)
$ sudo apache2ctl configtest (2)
$ sudo systemctl reload apache2 (3)
  1. 設定ファイルを有効にする
  2. 設定ファイルのテスト
  3. apache httpdの設定反映

この状態で http://nitter.matoken.org/ 及び https://nitter.matoken.org/ にアクセスしてみて Nitter が利用できたらOKです.

とりあえず一般公開しておきますが,今の https://nitter.net みたいにアクセス制限がしょっちゅうかかるようになったら制限するかもしれません.

環境

$ git -C ~nitter/nitter log -1
commit f392b6ca37e66c7c759aa98db23e0bdc62b39c3d (HEAD -> master, origin/master, origin/HEAD)
Author: Lukas Winkler <github@lw1.at>
Date:   Sun Feb 14 12:49:09 2021 +0100

    run optipng -o 9 on all images (#337)
$ dpkg-query -W apache2 redis* libsass-dev certbot
apache2 2.4.38-3+deb10u4
certbot 0.31.0-1+deb10u1
libsass-dev:amd64       3.5.5-4
redis-server    5:5.0.3-4+deb10u2
redis-tools     5:5.0.3-4+deb10u2
$ lsb_release -dr
Description:    Debian GNU/Linux 10 (buster)
Release:        10
$ uname -m
x86_64
]]>
https://matoken.org/blog/2021/02/17/self-hosting-the-lightweight-twitter-front-end-nitter/feed/ 3
twitterのbotがロックされてしまい困る https://matoken.org/blog/2016/04/08/troubled-bot-of-will-be-locked/ https://matoken.org/blog/2016/04/08/troubled-bot-of-will-be-locked/#respond Fri, 08 Apr 2016 13:26:31 +0000 http://matoken.org/blog/?p=1322

最近鹿児島らぐのMLの投稿をつぶやくだけの @kagolug_ml というbotを動かし始めたのですが,数件postした後投稿されていません.一緒にLingrにもpostしていますがそちらは投稿されています.

手動で叩いてみるとこのようなエラーが帰ってきました.

*** server reports: "To protect our users from spam and other malicious activity, this account is temporarily locked. Please log in to https://twitter.com to unlock your account."
check your password or configuration.
access failure on: https://api.twitter.com/1.1/statuses/home_timeline.json
to automatically wait for a connect, use -hold.

twitterにspamアカウントだと疑われてロックされしまったようですorz

webを見るとこんな画面に.

25702345904 5e021b7e7c

アンロックにはSMS認証が必要でした.

26281259996 618b1b93fa

認証後電話番号がアカウントに登録されてしまいますが,削除は可能でした.

26281260076 269fa6edef

しかし未だ数件した投稿していないし投稿間隔も十分開いていたので問題無いと思うのですがフォロワーが少ないのがいけないのかもしれませんね…….

]]>
https://matoken.org/blog/2016/04/08/troubled-bot-of-will-be-locked/feed/ 0
端末で動くTwitterClient Rainbowstream https://matoken.org/blog/2015/02/07/terminal_twitter_client_rainbowstream/ https://matoken.org/blog/2015/02/07/terminal_twitter_client_rainbowstream/#respond Fri, 06 Feb 2015 23:30:35 +0000 http://matoken.org/blog/?p=724

確かOSSJで見かけて知ったのだと思うのですが,

端末上で動作するTwitterのRainbowstreamというソフトウェアを知りました.

ユーザーストリーム対応で端末上にユーザストリームや検索結果リストなどが表示できます.画像をアスキーアートで表示する機能もあります.

導入

pipで入る

$ sudo apt-get install python-pip python-dev
$ sudo pip install rainbowstream PySocks Pillow

初回起動時に認証のためブラウザが起動する.認証ご表示されたpinを端末に貼り付ける.認証情報は ~/.rainbow_oauth に保存されるので要らなくなったら消す.
無くても動くけど無いと設定変更が出来ないので設定ファイルの用意をする.

% wget https://raw.githubusercontent.com/DTVD/rainbowstream/master/rainbowstream/colorset/config -O /tmp/config
% mv /tmp/config ~/.rainbow_config.json

GNU Screen のウィンドウ分割モードだと崩れてしまうので,小さめのウィンドウに表示するといい感じです.以下の画像はawesome で端末を2つ表示してRainbowstreamを実行した端末を小さくしているところです.
20150202_07:02:05-608

画像のアスキーアート表示は楽しいのですが,一気にログが流れてしまうのでoffにしちゃいました.
自作のPerl Script で昔作ったものがあるのですが,Rainbowstreamのほうがカラフルで見た目がいい感じです.

]]> https://matoken.org/blog/2015/02/07/terminal_twitter_client_rainbowstream/feed/ 0